package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DeclarationLMReport;
import com.ruoyi.system.service.IDeclarationLMReportService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 联盟报表Controller
 * 
 * @author triangle
 * @date 2022-08-13
 */
@Controller
@RequestMapping("/system/declarationLMReport")
public class DeclarationLMReportController extends BaseController
{
    private String prefix = "system/declarationLMReport";

    @Autowired
    private IDeclarationLMReportService declarationLMReportService;

    @RequiresPermissions("system:declarationLMReport:view")
    @GetMapping()
    public String declarationLMReport()
    {
        return prefix + "/declarationLMReport";
    }

    /**
     * 查询联盟报表列表
     */
    @RequiresPermissions("system:declarationLMReport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DeclarationLMReport declarationLMReport)
    {
        startPage();
        List<DeclarationLMReport> list = declarationLMReportService.selectDeclarationLMReportList(declarationLMReport);
        return getDataTable(list);
    }

    /**
     * 导出联盟报表列表
     */
    @RequiresPermissions("system:declarationLMReport:export")
    @Log(title = "联盟报表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DeclarationLMReport declarationLMReport)
    {
        List<DeclarationLMReport> list = declarationLMReportService.selectDeclarationLMReportList(declarationLMReport);
        ExcelUtil<DeclarationLMReport> util = new ExcelUtil<DeclarationLMReport>(DeclarationLMReport.class);
        return util.exportExcel(list, "联盟报表数据");
    }

    /**
     * 新增联盟报表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存联盟报表
     */
    @RequiresPermissions("system:declarationLMReport:add")
    @Log(title = "联盟报表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DeclarationLMReport declarationLMReport)
    {
        return toAjax(declarationLMReportService.insertDeclarationLMReport(declarationLMReport));
    }

    /**
     * 修改联盟报表
     */
    @RequiresPermissions("system:declarationLMReport:edit")
    @GetMapping("/edit/{decId}")
    public String edit(@PathVariable("decId") Long decId, ModelMap mmap)
    {
        DeclarationLMReport declarationLMReport = declarationLMReportService.selectDeclarationLMReportByDecId(decId);
        mmap.put("declarationLMReport", declarationLMReport);
        return prefix + "/edit";
    }

    /**
     * 修改保存联盟报表
     */
    @RequiresPermissions("system:declarationLMReport:edit")
    @Log(title = "联盟报表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DeclarationLMReport declarationLMReport)
    {
        return toAjax(declarationLMReportService.updateDeclarationLMReport(declarationLMReport));
    }

    /**
     * 删除联盟报表
     */
    @RequiresPermissions("system:declarationLMReport:remove")
    @Log(title = "联盟报表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(declarationLMReportService.deleteDeclarationLMReportByDecIds(ids));
    }
}
